package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.SocCheckAddDTO;
import org.jsola.hr.dto.SocCheckUpdateDTO;
import org.jsola.hr.entity.SocCheckDO;
import org.jsola.hr.query.SocCheckQuery;
import org.jsola.hr.service.ISocCheckService;
import org.jsola.hr.vo.SocCheckVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 社保校验表
 *
 * @author zhr
 */
@Component
public class SocCheckTestHelper extends BaseTestHelper {
    
    @Autowired
    private ISocCheckService socCheckService;

    /**
     * 生成add测试数据
     * @return SocCheckAddDTO
     */
    public SocCheckAddDTO getSocCheckAddDTO(){
        SocCheckAddDTO socCheckAddDTO = new SocCheckAddDTO();
        socCheckAddDTO.setSocMonthId(getRandomValue("varchar",32));
        socCheckAddDTO.setFileUrl(getRandomValue("text",2147483647));
        socCheckAddDTO.setFileName(getRandomValue("varchar",50));
        socCheckAddDTO.setEmpDifferenceNum(SafeKit.getInteger(getRandomValue("int",0)));
        socCheckAddDTO.setSocDifferenceAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        socCheckAddDTO.setPfDifferenceAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        socCheckAddDTO.setServiceCostDifference(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        socCheckAddDTO.setSocialDifference(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        socCheckAddDTO.setAccumulationDifference(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        socCheckAddDTO.setCompanyId(getRandomValue("varchar",32));
        socCheckAddDTO.setYear(getRandomValue("varchar",5));
        socCheckAddDTO.setMonth(getRandomValue("varchar",5));
        socCheckAddDTO.setCheckType(SafeKit.getInteger(getRandomValue("varchar",2)));
        return socCheckAddDTO;
    }


    /**
     * 生成update测试数据
     * @return SocCheckUpdateDTO
     */
    public SocCheckUpdateDTO getSocCheckUpdateDTO(SocCheckVO socCheckVO){
        return socCheckService.selectDOById(socCheckVO.getId(), SITE_ID).to(SocCheckUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return SocCheckQuery
     */
    public SocCheckQuery getSocCheckQuery() {
        SocCheckQuery socCheckQuery = new SocCheckQuery();
        List<SocCheckDO> socCheckDOList = socCheckService.list(new SocCheckDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(socCheckDOList)) {
            SocCheckDO socCheckDO = socCheckDOList.get(0);
            socCheckQuery = socCheckDO.to(SocCheckQuery.class);
        }
        return socCheckQuery;
    }

    /**
     * 保存示例
     * @return SocCheckVO
     */
    public SocCheckVO saveSocCheckExample(){
        SocCheckAddDTO addDTO = this.getSocCheckAddDTO();
        SocCheckVO socCheckVO = socCheckService.save(addDTO,buildTokenUser());
        return socCheckVO;
    }


}

